function ImgScroll(){
	this.index=0;
	this.imgs=$(".img-list");
	this.navs=$(".banner-nav-list>li");
	this.banner=$(".banner");
	this.btn=$(".btn");
	this.leftBtn=$(".toLeft");
	this.rightBtn=$(".toRight");
	this.init();
}
ImgScroll.prototype={
	init:function(){
		this.autoPlay();
		this.banHover();
		this.navHover();
		this.click();
		
	},
	autoPlay:function(){
		this.timer=setInterval(function(){
			this.tabImg();
			this.tabNav();
		}.bind(this),4000)
	},
	tabNav:function(){		
		this.navs.eq(this.index).addClass("active").siblings().removeClass("active");
	},
	tabImg:function(){
		this.index++;
		this.imgs.find("img").animate({width:1920,height:700},0)	
		this.imgs.animate({left:-this.index*1920-(1920-$(window).width())/2, top:-100 },0).stop().animate({left:-this.index*$(window).width(),top:0},4000).
		find("img").stop().animate({width:$(window).width(), height:500},4000)
		if( this.index == 6){
			this.imgs.animate({left:-(1920-$(window).width())/2},0);
			this.index = 0; 
		}					
	},
	banHover:function(){
		this.banner.hover(
			function(){
				clearInterval(this.timer);
				this.btn.fadeIn(1000)
			}.bind(this),
			function(){
				this.autoPlay();
				this.btn.fadeOut(1000)
			}.bind(this)
		)
	},
	navHover:function(){//难度最大的地方
		var self = this;//注意写法
		this.navs.on("mouseover",function(){
			clearInterval(self.timer);
			self.index=$(this).index()-1;
			self.tabImg();
			self.tabNav();
		})
	},
	click:function(){
		this.leftBtn.on("click",function(){
			this.clickMove(this.leftBtn);
		}.bind(this))
		
		this.rightBtn.on("click",function(){
			this.clickMove(this.rightBtn);
		}.bind(this))
	},
	clickMove:function(obj){
		if(obj.attr("class")=="toLeft"){
			this.index--;//注意：指的是下面文字的高亮显示
			if(this.index==-1){
				this.index=0;
			}
		}else{
			this.index++;
			if(this.index==6){
				this.index=5;
			}
		}
		this.imgs.find("img").animate({width:1920,height:700},0)	
		this.imgs.animate({left:-this.index*1920-(1920-$(window).width())/2,top:-100},0).stop().animate({left:-this.index*$(window).width(),top:0},4000).
		find("img").stop().animate({width:$(window).width(), height:500},4000)
		this.tabNav();
	}
}			


